/**
* Class Name: iFulfillRoadMapCntrlr
* Author: Accenture
* Date: 13-July-2011
* Requirement/Project Name: iFulfill
* Requirement/Project Description: Class implements to display the FI object Road map 
*/

public with sharing class iFulfillRoadMapCntrlr
{
    private Fullfilment_Item__c iFulfillItem = null;
    
     // Wrapper class to Display road map for  FI     
    class FullfilmentItemRoadMap 
    {
        public String functionName {get;set;}
        public boolean isCurrentState{get;set;}
        public boolean renderArrow{get;set;}
        
        public FullfilmentItemRoadMap (String function, Boolean checkBox, Boolean arrow)
        {
            functionName = function;
            isCurrentState = checkBox;
            renderArrow = arrow;
        }
    }
    
   /** Constructor **/
    public iFulfillRoadMapCntrlr(ApexPages.StandardController controller)
    {
        iFulfillItem = (Fullfilment_Item__c)controller.getRecord();
    }
    
    /**Returns workflow stages associated with  FI.**/
    public List<FullfilmentItemRoadMap > getStages()
    {
           List<FullfilmentItemRoadMap > roadMapWrapperList = new  List<FullfilmentItemRoadMap>();
           List<Workflow_Stage__C> workflowStageList= [select Name,id from Workflow_Stage__C where Workflow_Code__c = :iFulfillItem.Workflow_Code__c order by sequence__c];
           
           for(Integer i =0 ; i< workflowStageList.size() ; i++)
           {
                 Workflow_Stage__C workflowStageObj = workflowStageList.get(i);
                 
                 // To check last stage of the workflow to remove the the down arrow
                 
                 if(i == workflowStageList.size() -1 )
                 {
                     roadMapWrapperList.add(new FullfilmentItemRoadMap (workflowStageObj.name, workflowStageObj.name.equalsIgnoreCase(iFulfillItem.Current_Function_Name__c), false));
                 }
                 else
                 {
                   roadMapWrapperList.add(new FullfilmentItemRoadMap (workflowStageObj.name, workflowStageObj.name.equalsIgnoreCase(iFulfillItem.Current_Function_Name__c) ,true));
                 }
                 
           }
           
           return roadMapWrapperList ;
    }

   
}